package cn.akira.domain.strategy.service.rule.chain.factory;

import cn.akira.domain.strategy.repository.IStrategyRepository;
import cn.akira.domain.strategy.service.rule.chain.ILogicChain;
import cn.akira.domain.strategy.service.rule.chain.factory.engine.ILogicChainEngine;
import cn.akira.domain.strategy.service.rule.chain.factory.engine.impl.LogicChainEngine;
import lombok.*;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Map;

/**
 * @author fjl95
 * @date 2025/5/15
 * @description
 */
@Service
public class DefaultChainFactory {

    private final Map<String,ILogicChain> logicChainGroup;
    @Resource
    protected IStrategyRepository strategyRepository;

    //构造方法，自动注入所有链到map，因为在@component上加了注释
    public DefaultChainFactory(Map<String, ILogicChain> logicChainGroup, IStrategyRepository repository) {
        this.logicChainGroup = logicChainGroup;
        this.strategyRepository = repository;
    }
    //返回引擎
    public ILogicChainEngine openChainGroup(String[] ruleModels) {
        return new LogicChainEngine(logicChainGroup,ruleModels);

    }

    @Data
    @Builder
    @AllArgsConstructor
    @NoArgsConstructor
    public static class StrategyAwardVO {
        /** 抽奖奖品ID - 内部流转使用 */
        private Integer awardId;
        /**  */
        private String logicModel;
    }

}
